/*
 * Copyright (c) 2011 Ball State University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package edu.bsu.android.gtv.apps.bconnected.objects;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Person object
 * @author Kyle Parker, University Computing Services
 */
public class Person implements Comparable<Person> {
	private String address1;
	private String address2;
	private String advisingCenter;
	private String advisorType;
	private String advisorName;
	private String bsuID;
	private String buildingCode;
	private String buildingDesc;
	private String city;
	private String connectionTypeID;
	private String connectionTypeName;
	private String courseCount;
	private String courseEmail;
	private String courseInfo;
	private String courseNum;
	private String courseRefNum;
	private String courseTitle;
	private URL courseURL;
	private String courseWithTitle;
	private String dayTime;
	private String department;
	private String discCode;
	private String emailAddress;
	private String error;
	private String firstName;
	private String lastName;
	private String latitude;
	private String loginGuid;
	private String longitude;
	private String memberRole;
	private String memberRoleID;
	private String memberTypeID;
	private String middleName;
	private String namePrefix;
	private String nameSuffix;
	private String office;
	private String personType;
	private String phone;
	private String privacyRestriction;
	private String role;
	private String room;
	private String section;
	private boolean starred;
	private String state;
	private String titleRank;
	private String zip;

	public String getAddress1() {		
		return address1;
	}
	public void setAddress1(String value) {
		this.address1 = value.trim();
	}

	public String getAddress2() {		
		return address2;
	}
	public void setAddress2(String value) {
		this.address2 = value.trim();
	}

	public String getAdvisingCenter() {		
		return advisingCenter;
	}
	public void setAdvisingCenter(String value) {
		this.advisingCenter = value.trim();
	}

	public String getAdvisorName() {		
		return advisorName;
	}
	public void setAdvisorName(String value) {
		this.advisorName = value.trim();
	}

	public String getAdvisorType() {		
		return advisorType;
	}
	public void setAdvisorType(String value) {
		this.advisorType = value.trim();
	}

	public String getBSUID() {		
		return bsuID;
	}
	public void setBSUID(String value) {
		this.bsuID = value.trim();
	}
	
	public String getBuildingCode() {		
		return buildingCode;
	}
	public void setBuildingCode(String value) {
		this.buildingCode = value.trim();
	}
	
	public String getBuildingDesc() {		
		return buildingDesc;
	}
	public void setBuildingDesc(String value) {
		this.buildingDesc = value.trim();
	}

	public String getCity() {		
		return city;
	}
	public void setCity(String value) {
		this.city = value.trim();
	}
	
	public String getConnectionTypeID() {		
		return connectionTypeID;
	}
	public void setConnectionTypeID(String value) {
		this.connectionTypeID = value.trim();
	}
	
	public String getConnectionTypeName() {		
		return connectionTypeName;
	}
	public void setConnectionTypeName(String value) {
		this.connectionTypeName = value.trim();
	}
	
	public String getCourseCount() {		
		return courseCount;
	}
	public void setCourseCount(String value) {
		this.courseCount = value.trim();
	}
	
	public String getCourseInfo() {		
		return courseInfo;
	}
	public void setCourseInfo(String value) {
		this.courseInfo = value.trim();
	}
	
	public String getCourseEmail() {		
		return courseEmail;
	}
	public void setCourseEmail(String value) {
		this.courseEmail = value.trim();
	}
	
	public String getCourseNum() {		
		return courseNum;
	}
	public void setCourseNum(String value) {
		this.courseNum = value.trim();
	}
	
	public String getCourseRefNum() {		
		return courseRefNum;
	}
	public void setCourseRefNum(String value) {
		this.courseRefNum = value.trim();
	}
	
	public String getCourseTitle()  {		
		return courseTitle;
	}
	public void setCourseTitle(String value) {
		this.courseTitle = value.trim();
	}	
	
	public URL getCourseURL() {
		return courseURL;
	}	
	public void setCourseURL(String value) {
		try {
			this.courseURL = new URL(value);
		} catch (MalformedURLException e) {
			this.courseURL = null;
		}
	}
	
	public String getCourseWithTitle() {		
		return courseWithTitle;
	}
	public void setCourseWithTitle(String value) {
		this.courseWithTitle = value.trim();
	}
	
	public String getDayTime() {		
		return dayTime;
	}
	public void setDayTime(String value) {
		this.dayTime = value.trim();
	}
	
	public String getDepartment() {		
		return department;
	}	
	public void setDepartment(String value) {
		this.department = value.trim();
	}
	
	public String getDisciplineCode() {		
		return discCode;
	}
	public void setDisciplineCode(String value)  {
		this.discCode = value.trim();
	}

	public String getEmailAddress() {		
		return emailAddress;
	}
	public void setEmailAddress(String value) {
		this.emailAddress = value.trim();
	}
	
	public String getError() {		
		return error;
	}
	public void setError(String value) {
		this.error = value.trim();
	}

	public String getFirstName() {		
		return firstName;
	}
	public void setFirstName(String value) {
		this.firstName = value.trim();
	}
	
	public String getLastName() {		
		return lastName;
	}
	public void setLastName(String value) {
		this.lastName = value.trim();
	}

	public String getLatitude() {
		return latitude;
	}
	public void setLatitude(String value) {
		this.latitude = value.trim();
	}

	public String getLoginGuid() {
		return loginGuid;
	}
	public void setLoginGuid(String value) {
		this.loginGuid = value.trim();
	}

	public String getLongitude() {
		return longitude;
	}
	public void setLongitude(String value) {
		this.longitude = value.trim();
	}

	public String getMemberRole() {		
		return memberRole;
	}
	public void setMemberRole(String value) {
		this.memberRole = value.trim();
	}

	public String getMemberRoleID() {		
		return memberRoleID;
	}
	public void setMemberRoleID(String value) {
		this.memberRoleID = value.trim();
	}

	public String getMemberTypeID() {		
		return memberTypeID;
	}
	public void setMemberTypeID(String value) {
		this.memberTypeID = value.trim();
	}

	public String getMiddleName() {		
		return middleName;
	}
	public void setMiddleName(String value) {
		this.middleName = value.trim();
	}

	public String getNamePrefix() {		
		return namePrefix;
	}
	public void setNamePrefix(String value) {
		this.namePrefix = value.trim();
	}

	public String getNameSuffix() {		
		return nameSuffix;
	}
	public void setNameSuffix(String value) {
		this.nameSuffix = value.trim();
	}

	public String getOffice() {		
		return office;
	}
	public void setOffice(String value) {
		this.office = value.trim();
	}

	public String getPersonType() {		
		return personType;
	}
	public void setPersonType(String value) {
		this.personType = value.trim();
	}

	public String getPhone() {		
		return phone;
	}
	public void setPhone(String value) {
		this.phone = value.trim();
	}

	public String getPrivacyRestriction() {		
		return privacyRestriction;
	}
	public void setPrivacyRestriction(String value) {
		this.privacyRestriction = value.trim();
	}

	public String getRoom() {		
		return room;
	}
	public void setRoom(String value) {
		this.room = value.trim();
	}

	public String getRole() {		
		return role;
	}
	public void setRole(String value) {
		this.role = value.trim();
	}

	public String getSection()  {		
		return section;
	}
	public void setSection(String value) {
		this.section = value.trim();
	}

	public boolean getStarred() {		
		return starred;
	}
	public void setStarred(boolean value) {
		this.starred = value;
	}

	public String getState() {		
		return state;
	}
	public void setState(String value) {
		this.state = value.trim();
	}

	public String getTitleRank() {		
		return titleRank;
	}
	public void setTitleRank(String value) {
		this.titleRank = value.trim();
	}

	public String getZip() {		
		return zip;
	}
	public void setZip(String value) {
		this.zip = value.trim();
	}
	
	public Person copy() {
		Person copy = new Person();
		copy.address1 = address1;
		copy.address2 = address2;
		copy.advisingCenter = advisingCenter;
		copy.advisorName = advisorName;
		copy.advisorType = advisorType;
		copy.bsuID = bsuID;
		copy.buildingCode = buildingCode;
		copy.buildingDesc = buildingDesc;
		copy.city = city;
		copy.connectionTypeID = connectionTypeID;
		copy.connectionTypeName = connectionTypeName;
		copy.courseCount = courseCount;
		copy.courseEmail = courseEmail;
		copy.courseInfo = courseInfo;
		copy.courseNum = courseNum;
		copy.courseRefNum = courseRefNum;
		copy.courseTitle = courseTitle;
		copy.courseURL = courseURL;
		copy.courseWithTitle = courseWithTitle;
		copy.dayTime = dayTime;
		copy.department = department;
		copy.discCode = discCode;
		copy.emailAddress = emailAddress;
		copy.error = error;
		copy.firstName = firstName;
		copy.lastName = lastName;
		copy.latitude = latitude;
		copy.loginGuid = loginGuid;
		copy.longitude = longitude;
		copy.memberRole = memberRole;
		copy.memberRoleID = memberRoleID;
		copy.memberTypeID = memberTypeID;
		copy.middleName = middleName;
		copy.namePrefix = namePrefix;
		copy.nameSuffix = nameSuffix;
		copy.office = office;
		copy.personType = personType;
		copy.phone = phone;
		copy.privacyRestriction = privacyRestriction;
		copy.role = role;
		copy.room = room;
		copy.starred = starred;
		copy.state = state;
		copy.section = section;
		copy.titleRank = titleRank;
		copy.zip = zip;
		return copy;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime * result + ((address1 == null) ? 0 : address1.hashCode());
		result = prime * result + ((address2 == null) ? 0 : address2.hashCode());
		result = prime * result + ((advisingCenter == null) ? 0 : advisingCenter.hashCode());
		result = prime * result + ((advisorName == null) ? 0 : advisorName.hashCode());
		result = prime * result + ((advisorType == null) ? 0 : advisorType.hashCode());
		result = prime * result + ((bsuID == null) ? 0 : bsuID.hashCode());
		result = prime * result + ((buildingCode == null) ? 0 : buildingCode.hashCode());
		result = prime * result + ((buildingDesc == null) ? 0 : buildingDesc.hashCode());
		result = prime * result + ((city == null) ? 0 : city.hashCode());
		result = prime * result + ((connectionTypeID == null) ? 0 : connectionTypeID.hashCode());
		result = prime * result + ((connectionTypeName == null) ? 0 : connectionTypeName.hashCode());
		result = prime * result + ((courseCount == null) ? 0 : courseCount.hashCode());
		result = prime * result + ((courseEmail == null) ? 0 : courseEmail.hashCode());
		result = prime * result + ((courseInfo == null) ? 0 : courseInfo.hashCode());
		result = prime * result + ((courseNum == null) ? 0 : courseNum.hashCode());
		result = prime * result + ((courseRefNum == null) ? 0 : courseRefNum.hashCode());
		result = prime * result + ((courseTitle == null) ? 0 : courseTitle.hashCode());
		result = prime * result + ((courseURL == null) ? 0 : courseURL.hashCode());
		result = prime * result + ((courseWithTitle == null) ? 0 : courseWithTitle.hashCode());
		result = prime * result + ((dayTime == null) ? 0 : dayTime.hashCode());
		result = prime * result + ((department == null) ? 0 : department.hashCode());
		result = prime * result + ((discCode == null) ? 0 : discCode.hashCode());
		result = prime * result + ((emailAddress == null) ? 0 : emailAddress.hashCode());
		result = prime * result + ((error == null) ? 0 : error.hashCode());
		result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
		result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
		result = prime * result + ((latitude == null) ? 0 : latitude.hashCode());
		result = prime * result + ((loginGuid == null) ? 0 : loginGuid.hashCode());
		result = prime * result + ((longitude == null) ? 0 : longitude.hashCode());
		result = prime * result + ((memberRole == null) ? 0 : memberRole.hashCode());
		result = prime * result + ((memberRoleID == null) ? 0 : memberRoleID.hashCode());
		result = prime * result + ((memberTypeID == null) ? 0 : memberTypeID.hashCode());
		result = prime * result + ((middleName == null) ? 0 : middleName.hashCode());
		result = prime * result + ((namePrefix == null) ? 0 : namePrefix.hashCode());
		result = prime * result + ((nameSuffix == null) ? 0 : nameSuffix.hashCode());
		result = prime * result + ((office == null) ? 0 : office.hashCode());
		result = prime * result + ((personType == null) ? 0 : personType.hashCode());
		result = prime * result + ((phone == null) ? 0 : phone.hashCode());
		result = prime * result + ((privacyRestriction == null) ? 0 : privacyRestriction.hashCode());
		result = prime * result + ((role == null) ? 0 : role.hashCode());
		result = prime * result + ((room == null) ? 0 : room.hashCode());
		result = prime * result + ((section == null) ? 0 : section.hashCode());
		result = prime * result + ((state == null) ? 0 : state.hashCode());
		result = prime * result + ((titleRank == null) ? 0 : titleRank.hashCode());
		result = prime * result + ((zip == null) ? 0 : zip.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj)  {
		if (this == obj) { return true; }
		
		if (obj == null) { return false; }
		
		if (getClass() != obj.getClass()) { return false; }
		
		Person other = (Person) obj;
		
		if (address1 == null) {
			if (other.address1 != null) { return false; }
		} else if (!address1.equals(other.address1)) { return false; }
		
		if (address2 == null) {
			if (other.address2 != null) { return false; }
		} else if (!address2.equals(other.address2)) { return false; }
		
		if (advisingCenter == null) {
			if (other.advisingCenter != null) { return false; }
		} else if (!advisingCenter.equals(other.advisingCenter)) { return false; }
		
		if (advisorName == null) {
			if (other.advisorName != null) { return false; }
		} else if (!advisorName.equals(other.advisorName)) { return false; }
		
		if (advisorType == null) {
			if (other.advisorType != null) { return false; }
		} else if (!advisorType.equals(other.advisorType)) { return false; }
		
		if (bsuID == null) {
			if (other.bsuID != null) { return false; }
		} else if (!bsuID.equals(other.bsuID)) { return false; }

		if (buildingCode == null)  {
			if (other.buildingCode != null) { return false; }
		}  else if (!buildingCode.equals(other.buildingCode)) { return false; }
		
		if (buildingDesc == null) {
			if (other.buildingDesc != null) { return false; }
		}  else if (!buildingDesc.equals(other.buildingDesc)) { return false; }
		
		if (city == null) {
			if (other.city != null) { return false; }
		} else if (!city.equals(other.city)) { return false; }
		
		if (connectionTypeID == null) {
			if (other.connectionTypeID != null) { return false; }
		}  else if (!connectionTypeID.equals(other.connectionTypeID)) { return false; }
		
		if (connectionTypeName == null) {
			if (other.connectionTypeName != null) { return false; }
		} else if (!connectionTypeName.equals(other.connectionTypeName)) { return false; }
		
		if (courseInfo == null) {
			if (other.courseInfo != null) { return false; }
		}  else if (!courseInfo.equals(other.courseInfo)) { return false; }
		
		if (courseEmail == null) {
			if (other.courseEmail != null) { return false; }
		}  else if (!courseEmail.equals(other.courseEmail)) { return false; }
		
		if (courseCount == null) {
			if (other.courseCount != null) { return false; }
		}  else if (!courseCount.equals(other.courseCount)) { return false; }
		
		if (courseNum == null) {
			if (other.courseNum != null) { return false; }
		} else if (!courseNum.equals(other.courseNum)) { return false; }
		
		if (courseRefNum == null) {
			if (other.courseRefNum != null) { return false; }
		}  else if (!courseRefNum.equals(other.courseRefNum)) { return false; }
		
		if (courseTitle == null) {
			if (other.courseTitle != null) { return false; }
		} else if (!courseTitle.equals(other.courseTitle)) { return false; }
		
		if (courseURL == null)  {
			if (other.courseURL != null) { return false; }
		}  else if (!courseURL.equals(other.courseURL)) { return false; }
		
		if (courseWithTitle == null) {
			if (other.courseWithTitle != null) { return false; }
		} else if (!courseWithTitle.equals(other.courseWithTitle)) { return false; }
		
		if (dayTime == null)  {
			if (other.dayTime != null) { return false; }
		} else if (!dayTime.equals(other.dayTime)) { return false; }
		
		if (department == null) {
			if (other.department != null) { return false; }
		} else if (!department.equals(other.department)) { return false; }
		
		if (discCode == null) {
			if (other.discCode != null) { return false; }
		} else if (!discCode.equals(other.discCode)) { return false; }
		
		if (emailAddress == null) {
			if (other.emailAddress != null) { return false; }
		} else if (!emailAddress.equals(other.emailAddress)) { return false; }
		
		if (error == null) {
			if (other.error != null) { return false; }
		} else if (!error.equals(other.error)) { return false; }
		
		if (firstName == null)  {
			if (other.firstName != null) { return false; }
		} else if (!firstName.equals(other.firstName)) { return false; }
		
		if (lastName == null) {
			if (other.lastName != null) { return false; }
		} else if (!lastName.equals(other.lastName)) { return false; }
		
		if (latitude == null) {
			if (other.latitude != null) { return false; }
		} else if (!latitude.equals(other.latitude)) { return false; }
		
		if (loginGuid == null) {
			if (other.loginGuid != null) { return false; }
		} else if (!loginGuid.equals(other.loginGuid)) { return false; }
		
		if (longitude == null) {
			if (other.longitude != null) { return false; }
		} else if (!longitude.equals(other.longitude)) { return false; }
		
		if (memberRole == null) {
			if (other.memberRole != null) { return false; }
		} else if (!memberRole.equals(other.memberRole)) { return false; }
		
		if (memberRoleID == null) {
			if (other.memberRoleID != null) { return false; }
		} else if (!memberRoleID.equals(other.memberRoleID)) { return false; }
		
		if (memberTypeID == null) {
			if (other.memberTypeID != null) { return false; }
		} else if (!memberTypeID.equals(other.memberTypeID)) { return false; }
		
		if (middleName == null) {
			if (other.middleName != null) { return false; }
		} else if (!middleName.equals(other.middleName)) { return false; }
		
		if (namePrefix == null) {
			if (other.namePrefix != null) { return false; }
		} else if (!namePrefix.equals(other.namePrefix)) { return false; }
		
		if (nameSuffix == null) {
			if (other.nameSuffix != null) { return false; }
		} else if (!nameSuffix.equals(other.nameSuffix)) { return false; }
		
		if (office == null) {
			if (other.office != null) { return false; }
		} else if (!office.equals(other.office)) { return false; }
		
		if (personType == null) {
			if (other.personType != null) { return false; }
		} else if (!personType.equals(other.personType)) { return false; }
		
		if (phone == null) {
			if (other.phone != null) { return false; }
		} else if (!phone.equals(other.phone)) { return false; }
		
		if (privacyRestriction == null) {
			if (other.privacyRestriction != null) { return false; }
		} else if (!privacyRestriction.equals(other.privacyRestriction)) { return false; }
		
		if (role == null) {
			if (other.role != null) { return false; }
		} else if (!role.equals(other.role)) { return false; }
		
		if (room == null) {
			if (other.room != null) { return false; }
		} else if (!room.equals(other.room)) { return false; }
		
		if (section == null) {
			if (other.section != null) { return false; }
		} else if (!section.equals(other.section)) { return false; }
		
		if (state == null) {
			if (other.state != null) { return false; }
		} else if (!state.equals(other.state)) { return false; }
		
		if (titleRank == null) {
			if (other.titleRank != null) { return false; }
		}  else if (!titleRank.equals(other.titleRank)) { return false; }
		
		if (zip == null) {
			if (other.zip != null) { return false; }
		} else if (!zip.equals(other.zip)) { return false; }
		
		return true;
	}

	public int compareTo(Person another) {
		if (another == null) return 1;
		return another.lastName.compareTo(lastName);
	}
}
